<?php

namespace app\common\model\xilujob;

use think\Exception;
use think\Model;

class ResumeFile extends Model
{
    // 表名
    protected $name = 'xilujob_resume_file';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    protected $append = [
        'createtime_text'
    ];

    public function getCreatetimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i", $value) : $value;
    }

    public static function getResumeFiles($userId){
        return ResumeFile::field('id,name,file,file_ext')->where('user_id',$userId)->select();
    }

}
